package com.accounting.client.remote.enumeration;

import java.util.List;

import corelib.client.CollectionUtil;

public class StockLocation {
	
	public final static StockLocation China     = new StockLocation(0,  "China", "中国");
	public final static StockLocation Sydney    = new StockLocation(1,  "Sydney", "悉尼");
	public final static List<StockLocation> All = CollectionUtil.newArrayList(China, Sydney);
	
	private int location;
	private String name;
	private String cname;
	
	public StockLocation(int loc, String name, String cname){
		this.location = loc;
		this.name = name;
		this.cname = cname;
	}

	public int getLocation() {
		return location;
	}

	public void setLocation(int location) {
		this.location = location;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null){
			return this == null;
		}
		
		if (!(obj instanceof StockLocation)){
			  return false;
		}
		
		StockLocation loc = (StockLocation) obj;
		return location == loc.getLocation();
	}

	public static StockLocation getLocationByType(int type){
		switch(type){
			case 0 : return StockLocation.China;
			case 1 : return StockLocation.Sydney;
			default: return null;
		}
	}
	
}
